package com.letoken.platform.repo.app.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.letoken.platform.repo.admin.req.mall.MallIssuDetailReq;
import com.letoken.platform.repo.admin.req.mall.MallStoreAccountListReq;
import com.letoken.platform.repo.admin.res.mall.MallIssuDetailRes;
import com.letoken.platform.repo.admin.res.mall.MallStoreAccountListRes;
import com.letoken.platform.repo.app.po.MallCirculationHistory;
import com.letoken.platform.repo.app.res.assets.QueryTokenAssetsHistoryRes;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * Le账户-资产历史交易日志 Mapper 接口
 * </p>
 *
 * @author 作者
 * @since 2022-12-10
 */
public interface MallCirculationHistoriesMapper extends BaseMapper<MallCirculationHistory> {

    Page<QueryTokenAssetsHistoryRes> queryTokenAssetsHistory(@Param("page")
                                                             Page<QueryTokenAssetsHistoryRes> page,
                                                             @Param("tokenId") String tokenId,
                                                             @Param("split") List<String> split,
                                                             @Param("userId") Integer userId);

//    Page<QueryLetokenHistoryRes> queryLetokenHistoryPage(@Param("page") Page<QueryLetokenHistoryRes> page,
//                                                         @Param("userId") Integer userId);


    Page<MallStoreAccountListRes> storeAccountList(@Param("page")  Page<MallStoreAccountListRes> page,@Param("req") MallStoreAccountListReq req);

    @Select("select ifnull(SUM(amount),0) from app_user_assets_history where type in (9) and DATE(create_time) = CURDATE()")
    BigDecimal getAmountByToday();

    @Select("select IFNULL(SUM(amount),0)from app_user_assets_history where type in (9) and to_days(now( ) ) - to_days( create_time) = 1  ")
    BigDecimal getAmountByYesterday();

    @Select("select IFNULL(SUM(amount),0) from app_user_assets_history where type in (9) and MONTH(create_time) = MONTH(NOW()) ")
    BigDecimal getAmountByMonth();
    @Select("select IFNULL(SUM(amount),0) from app_user_assets_history where type in (9)  ")
    BigDecimal getSumAmountBy();

    Page<MallIssuDetailRes> getMallIssueDetail(@Param("page")  Page<MallIssuDetailRes> page,@Param("req") MallIssuDetailReq req);
}
